package cn.tedu.boot04.mapper;

import cn.tedu.boot04.entity.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

/*此注释是将当前接口设置为映射接口，Mybatis框架会根据此接口中的内容生成对应的实现类在实现类里面生成对应的JDBC代码*/
@Mapper
public interface ProductMapper {
    @Insert("INSERT INTO product VALUES(null,#{title},#{price},#{num})")
    void insert(Product product);

    @Select("SELECT * FROM product")
    List<Product> select();

    @Delete("DELETE FROM product WHERE id=#{id}")
    void deleteByID(int id);

    @Update("UPDATE product SET title=#{title},price=#{price},num=#{num} WHERE id=#{id}")
    void update(Product product);
}
